import org.junit.Test;

import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author Yin_JC
 * @PackageName:PACKAGE_NAME
 * @Class:CompareLearning
 * @Description:
 *
 * 方法一：要使得一个类可以比较，需要实现Comparable接口并重写CompareTo方法
 * 方法二：Comparator
 * @date 2020/3/3 10:34
 */




public class CompareLearning {
    @Test
    public void stringCompare(){
        String[] strl = new String[]{"asd","SAd","ewff","a"};
        Arrays.sort(strl);
        System.out.println(Arrays.toString(strl));
    }

    @Test
    public void comparator(){
        String[] strl = new String[]{"asd","SAd","ewff","a"};
        Arrays.sort(strl, new Comparator<String>() {
            @Override
            public int compare(String s, String t1) {
                return -s.compareTo(t1);
            }
        });
        System.out.println(Arrays.toString(strl));
    }

    @Test
    public void inte(){
        BigInteger bg = new BigInteger(String.valueOf(111));
        BigInteger add = bg.add(bg);
        System.out.println(add);
    }
}
